package main

func search(nums []int, target int) int {

	var left, right, pivot int

	left, right = 0, len(nums)-1

	for left <= right {
		pivot = left + (right-left)>>2
		if nums[pivot] > target {
			right = pivot - 1
		} else if nums[pivot] < target {
			left = pivot + 1
		} else if nums[pivot] == target {
			return pivot
		}
	}
	return -1
}

func main() {
	var nums = []int{2, 3, 4, 5}

	var target = 2
	search(nums, target)
}
